package org.imraniqbal.mouseland;

import java.awt.Color;
import java.awt.Graphics2D;
import java.util.Vector;

import org.imraniqbal.engine.Game;
import org.imraniqbal.engine.GameController;
import org.imraniqbal.engine.GamePanel;
import org.imraniqbal.engine.Mappable;

public class MouselandPanel extends GamePanel<MouselandGame> {

	private static final long serialVersionUID = 1277595092386647906L;
	/**
	 * Creates a Game panel, with blue maze walls
	 * @param g current instance of game
	 * @author imran
	 */
	public MouselandPanel(Game g) {
		super(g);
		setMazeColor(new Color(0,0,255));
	}
	/**
	 * Creates a new game
	 * @author imran
	 */
	@Override
	public void newGame() {
		MouselandGame mg = new MouselandGame();
		setGame(mg);
		removeGc(getGc());
		setGc(new GameController<MouselandGame>(mg, this));
		
		repaint();

	}

	/**
	 * Handles the drawing of specific mappables
	 * @author imran
	 */
	@Override
	protected void DrawMappable(Vector<Mappable> mappable, Graphics2D g2d) {
		for( Mappable m : mappable){
			int y = m.getY();
			int x = m.getX();
			if( m instanceof Hero){
				DrawImage(g2d, x*GamePanel.defaultTileSize, y*GamePanel.defaultTileSize, creatImage("gfx/mouseland/person.png"));
			}
			else if( m instanceof Mouse){
				DrawImage(g2d, x*GamePanel.defaultTileSize, y*GamePanel.defaultTileSize, creatImage("gfx/mouseland/mouse.png"));
			}
			else if( m instanceof Exit){
				DrawImage(g2d, x*GamePanel.defaultTileSize, y*GamePanel.defaultTileSize, creatImage("gfx/mouseland/ladder.png"));
			}
			else{
				DrawImage(g2d, x*GamePanel.defaultTileSize, y*GamePanel.defaultTileSize, creatImage("gfx/mouseland/mousetrap.png"));
			}
		}
	}

}
